/**
 * futures : masterlink.futures.dao.GroupDao.java
 */
package masterlink.futures.dao;

import java.util.List;

import masterlink.futures.vo.Account;
import masterlink.futures.vo.GreekConclusion;
import masterlink.futures.vo.GreekPk;
import masterlink.futures.vo.Group;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;

/**
 * TODO Write the description
 *
 * @author : tonyyang
 * Create date : 2011/10/25
 * @version 1.0.0	
 */
@Repository
@Qualifier("GreekConclusionDao")
public class GreekConclusionDao extends TimesTenHibernateDao<GreekConclusion,GreekPk> {
	
	private static final String FIND_BY_GROUP="select c.* from greeks_limit a,fuminv b ,greeks_conclusion c where a.account=b.acno and a.broker=b.broker_id and a.account=c.account(+) and a.broker=c.broker and a.id=?";
	private static final String FIND_BY_ACC="select c.* from greeks_limit a,fuminv b ,greeks_conclusion c where a.account=b.acno and a.broker=b.broker_id and a.account=c.account(+) and a.broker=c.broker and a.id=? and a.account=?";
	
	public List<GreekConclusion> findByGroup(Group group) {
		if(group!=null){
			return super.findBySql(FIND_BY_GROUP, GreekConclusion.class, group.getId()) ;
		}
		return null;
	}
	
	public List<GreekConclusion> findByAccount(Group group,Account acc) {
		if(group!=null&&acc!=null){
			return super.findBySql(FIND_BY_ACC, GreekConclusion.class, group.getId(),acc.getId().getAcno()) ;
		}
		return null;
	}

}
